<!DOCTYPE html>
<html>
<html lang="zh_CN" style="overflow: hidden;">
<head>
	<meta charset="UTF-8">
	<title>后台管理系统</title>
    <meta name="author" content="BaiYY"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.validate.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.ididenify.js"></script>
</head>
<body >
	
	<div class="container">
	    <div class="row regpage">
	    	<div class="col-md-6 col-md-offset-3">
	    		<div class="panel panel-default">
				  <div class="panel-heading">
				    <h3 class="panel-title text-center" style="font-size: 20px;font-weight: bold;">代理详细信息填写</h3>
				  </div>
				  <div class="panel-body">
				    <form class="container-fluid" method="post" role="form" id="regForm">
				    
				        <div class="form-group">
				            <div class="col-sm-8 col-sm-offset-3 col-md-8">
				                <input type="text" class="form-control" name="name" id="name" placeholder="请输入真实姓名">
				            </div>
				        </div>
				
				        <div class="form-group">
				            <div class="col-sm-8 col-sm-offset-3 col-md-8">
				                <input type="text" class="form-control" name="card_id" id="card_id" placeholder="请输入身份证号">
				            </div>
				        </div>
						
						<div class="form-group">
				            <div class="col-sm-8 col-sm-offset-3 col-md-8">
				                <input type="text" class="form-control" name="bank_card" id="bank_card" placeholder="请输入银行卡号">
				            </div>
				        </div>
				        
				        <div class="form-group">
				            <div class="col-sm-8 col-sm-offset-3 col-md-8">
				                <input type="text" class="form-control" name="bank_name" id="bank_name" placeholder="请输入开户行">
				            </div>
				        </div>
				        
				        <div class="text-center form-group">
				            <div class="col-sm-8 col-sm-offset-3 col-md-8">
				            	<input type="submit" class="btn" value="保存" style="width:90px;background-color: #337ab7;color: #fff;"/>
				            </div>
				        </div>
				        
				    </form>
				    
				    <!--<div class="row text-center">
				        <hr />
				        <p>已是代理 <a href="login.html" style="font-weight:bold;color: #222;">直接登录</a></p>
				    </div>-->
				  </div>
				</div>
	    	</div>
	        </div>
	
	    </div>
	
	</div>
<script type="text/javascript">

	$.validator.setDefaults({
		submitHandler:function(){
			var tel = localStorage.getItem("tel");
			var bank_card = $.trim($("#bank_card").val());
			var bank_name = $.trim($("#bank_name").val());
			var name = $.trim($("#name").val());
			var card_id = $.trim($("#card_id").val());
            var url = "{:U('Admin/Login/saveInfo')}";
            $.ajax({
                type: "post",
                url: url,
                timeout : 5000, //超时时间设置，单位毫秒
                dataType: "json",
                data:{"tel":tel,"bank_card":bank_card,"bank_name":bank_name,"name":name,"card_id":card_id},
                success: function(data){
                	if(data == "success"){
                		alert("信息保存成功");
                		localStorage.removeItem("tel");
                		window.location.href="{:U('Admin/Login/login')}";
                	}else{
                		alert("保存失败");
                		window.location.href="{:U('Admin/Login/infoSave')}";
                	}
                }
            });
			
		}
	});
	
	$().ready(function(){
		$("#regForm").validate({
			rules: {
				name: "required",
				card_id: "required",
				
			    name: {
			    	required: true,
			    	minlength: 2
			    },
			    card_id: {
			    	required:true,
                    isIdCardNo:true
			    }
			},
		    messages: {
	  			name: "请输入您的真实姓名",
	  			card_id: "请输入您的身份证号",
		  		
		  		name: {
		  			required: "姓名是必填项",
		  			minlength: "真实姓名最少2位数"
		  		},
		  		card_id: {
		  			required:"身份证是必填项",
                    isIdCardNo: "请输入正确的身份证号"
		  		}
		    }
		});
	});
</script>
</body>
</html>